<?php

// Load Pinboard class
include 'PinboardClient.php';

// Grab the username and password
$username = strip_tags($_GET["delicious_username"]);
$password = strip_tags($_GET["delicious_password"]);

// Sanitize the URL, page title, tags and notes
$url   = urldecode($_GET["delicious_url"]);
$title = strip_tags(stripslashes($_GET["delicious_title"]));
$tags  = strip_tags($_GET["delicious_tags"]);
$notes = strip_tags(stripslashes($_GET["delicious_notes"]));

// Make sure notes is at least an empty string
if (!strlen($notes)) {
  $notes = "";
}

// Make sure tags is at least an empty string
if (!strlen($tags)) {
  $tags = "";
}

// Make sure the title is at least an empty string
if (!strlen($title)) {
  $notes = "";
}

// Authenticate with Pinboard
$d = new PinboardClient;
$d->setUsername($username);
$d->setPassword($password);

// Create a new post and save it
$d->addPost($url, $title, $tags, $notes);
?>
<br /><br />
<div style="padding-bottom:15px;padding-left:10px;color:#000;"><small>Your <a style="color:#000;" href="<?php echo $url; ?>">link</a> was posted to <a style="color:#000;" target="_blank" href="https://pinboard.in/u:<?php echo $username ?>/">your Pinboard account</a>.</small></div>
